﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FinalProject.Entities;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.ComponentModel;

namespace FinalProject.Web.ViewModels
{
    public class CreateTicketViewModel
    {
        public int Id { get; set; }
        [DisplayName("Ticket Number")]
        [Required]
        [StringLength(16)]
        public string Name { get; set; }
        [Required]
        [DataType(DataType.Currency)]
        [DisplayFormat(DataFormatString = "{0:C}")]
        public double TicketBalance { get; set; }

        public int ClientId { get; set; }
        public string ClientName { get; set; }

        public List<InventoryItem> Items { get; set; }
        public List<TicketItem> TicketItems { get; set; }

        public CreateTicketViewModel()
        {
            this.Items = new List<InventoryItem>();
        }

        public void CreateInventoryItems(List<Item> items)
        {
            this.Items.Clear();
            foreach (var item in items)
            {
                this.Items.Add(new InventoryItem
                {
                    Id = item.Id,
                    Name = item.Name,
                    Price = item.Price
                });
            }
        }
    }
}